﻿using System.Drawing;

namespace GraphDrawing2.V2.Graph.Model
{
    public interface IVisualItem : IVisualObject
    {
        PointF Position { get; set; }
    }

    public interface IVisualObject
    {
        /// <summary>
        /// Подсказки состояния объекта.
        /// </summary>
        StateHints Hints { get; set; }
    }

    public static class VisualExt
    {
        public static void SetHint(this IVisualObject obj, StateHints hints)
        {
            obj.Hints |= hints;
        }

        public static void ClearHint(this IVisualObject obj, StateHints hints)
        {
            obj.Hints &= ~hints;
        }

        public static bool IsSelected(this IVisualObject element)
        {
            return element.Hints.HasFlag(StateHints.SELECTED);
        }

        public static bool IsHovered(this IVisualObject element)
        {
            return element.Hints.HasFlag(StateHints.HOVERED);
        }

        public static PointF RelativeToOrigin(this PointF point, PointF originPoint)
        {
            return new PointF(point.X - originPoint.X, point.Y - originPoint.Y);
        }

        public static PointF Sum(this PointF p1, PointF p2)
        {
            return p1 + new SizeF(p2);
        }
    }
}